package com.atguigu.gulimall.cart.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Classname WebMVCConfig
 * @Description TODO
 * @Date 2021/8/23 16:02
 * @Author Anonymous
 */
@SuppressWarnings("all")
@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //所有的请求都会经过这个拦截器
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");
    }
}

